package net.sql.bean;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import net.dotool.BeanTools;
import net.dotool.StringTools;
import net.dotool.page.PageModel;

/**
 * @author 李岩飞
 * @email eliyanfei@126.com
 * @date 2018年7月20日上午9:43:08
 */
public class SqlParam {
	private String sqlName;// 根据该名称获取xml的对象
	private String tableId;
	// 关联xml里面的变量
	private Map<String, Object> paramsMap = new LinkedHashMap<String, Object>();
	// 查询替换?的变量
	private List<Object> paramList = new ArrayList<Object>();
	private PageModel pageModel;// 加入分页
	private String sql;
	private String mySelect;// 自定义查询
	private String myOrderby;// 自定义排序
	private String myTable;// 自定义表名字
	private String belong;// 数据库归属
	private String project;// 区分项目
	private String selectSql;

	public SqlParam(String sqlName) {
		this.sqlName = sqlName;
	}

	public void setSelectSql(String selectSql) {
		this.selectSql = selectSql;
	}

	public String getSelectSql() {
		return selectSql;
	}

	public void setProject(String project) {
		this.project = project;
	}

	public String getProject() {
		return project;
	}

	public void setMyOrderby(String myOrderby) {
		this.myOrderby = myOrderby;
	}

	public String getMyOrderby() {
		return myOrderby;
	}

	public String getMySelect() {
		return mySelect;
	}

	public void setMySelect(String mySelect) {
		this.mySelect = mySelect;
	}

	public void setBelong(String belong) {
		this.belong = belong;
	}

	public String getBelong() {
		return belong;
	}

	public void setSql(String sql) {
		this.sql = sql;
	}

	public String getSql() {
		return sql;
	}

	public SqlParam(String sqlName, Object bean) {
		this.sqlName = sqlName;
		paramsMap.putAll(BeanTools.bean2Map(bean));
	}

	public void setPageModel(PageModel pageModel) {
		this.pageModel = pageModel;
	}

	public PageModel getPageModel() {
		return pageModel;
	}

	public void setTableId(String tableId) {
		this.tableId = tableId;
	}

	public String getTableId() {
		return tableId;
	}

	public List<Object> getParamList() {
		return paramList;
	}

	public Map<String, Object> getParams() {
		return paramsMap;
	}

	public void addParams(Object... objects) {
		for (Object obj : objects) {
			paramList.add(obj);
		}
	}

	public String getSqlName() {
		if (StringTools.isNotBlank(project)) {
			return project + "_" + sqlName;
		}
		return sqlName;
	}

	public String getMyTable() {
		return myTable;
	}

	public void setMyTable(String myTable) {
		this.myTable = myTable;
	}

}
